In [1]:
from configparser import ConfigParser
from os.path import join
from os import pardir
In [2]:
config = ConfigParser()
config.read(join(pardir,'src','credentials.ini'))
Out[2]:
In [3]:
APP_KEY = config['twitter']['app_key']
APP_SECRET = config['twitter']['app_secret']
OAUTH_TOKEN = config['twitter']['oauth_token']
OAUTH_TOKEN_SECRET = config['twitter']['oauth_token_secret']
In [4]:
from twitter import oauth, Twitter, TwitterHTTPError
Esta es la molona librería que vamos a utilizar: https://github.com/sixohsix/twitter/tree/master
In [5]:
auth = oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,
APP_KEY, APP_SECRET)
twitter_api = Twitter(auth=auth)
twitter_api.retry = True
In [6]:
tweet = twitter_api.statuses.show(_id='628949369883000832')
In [7]:
tweet['text']
Out[7]:
In [8]:
femfreq_tweet_search = twitter_api.statuses.user_timeline(screen_name="femfreq", count=100)
In [9]:
femfreq_tweet_search[0]['user']['description']
Out[9]:
In [10]:
femfreq_tweet_search[-1]['text']
Out[10]:
In [11]:
tweets = twitter_api.search.tweets(q="#feminazi", count=100)
In [12]:
tweets['search_metadata']
Out[12]:
In [13]:
import pandas as pd
text_gathered = [tweet_data['text'] for tweet_data in tweets['statuses']]
num_tweets = len(text_gathered)
pd_tweets = pd.DataFrame( {'tweet_text': text_gathered,
'troll_tag': [False] * num_tweets})
In [14]:
pd_tweets.head()
Out[14]:
In [15]:
pd_tweets.to_csv('maybe_troll.csv')
In [16]:
ls